Your lab/homework must be submitted in Moodle with two files: (1) R Markdown format file (Rmd); (2) an html file. Other formats will not be accepted.
Recall the histogram for cut categories from the
diamonds data set:
library(plotly)
library(tidyverse)
diamonds %>%
plot_ly( x = ~cut, showlegend = FALSE ) %>%
add_histogram(hoverinfo = "x+y") %>%
dplyr::group_by( cut ) %>%
summarise(n = n()) %>%
add_text(
text = ~scales::comma(n), y = ~n,
textposition = "top middle",
cliponaxis = FALSE,
hoverinfo = "none"
)
Please add to it the following changes:
cut, but the internal division of each bar is
according to the clarity variable."Blues" palette.hoverlabel)."pink"."lightgray".span) of 1."green"."Cut" (instead of
“cut”)."darkred" and its
font to "Times New Roman"."darkorange"
(be careful not to change other things with it)."red". No
tooltip is associated with these values."Ugly, ugly plot" in the
"Old Standard TT" font at the top left corner.In addition, make sure that the data that plot_ly
utilizes is the minimum data necessary for the plot.
So that the resulting plot looks like this dubious creation: